<core:SET width='200'>
<core:SET content="content">

<core:SET title="Article categories management">
<core:WRAP file="/adm/adm.layout.html" placeholder="Content">

<core:include file="/adm/inc/inc.adm.tabs.html">

<h1 align="center"> </h1>

<SCRIPT language="javascript">

	function TypeChanged(value) {

		var linked1 = document.CategoryForm.linked1;
        var linked2 = document.CategoryForm.linked2;


		if (value==1) {
		   //linked1.style.visibility = "hidden";
           //linked2.style.visibility = "visible";
           linked1.disabled = true;
           linked2.disabled = false;

		} else if (value==2) {
           //linked1.style.visibility = "visible";
           //linked2.style.visibility = "hidden";
           linked1.disabled = false;
           linked2.disabled = true;
		} else {
           //linked1.style.visibility = "hidden";
           //linked2.style.visibility = "hidden";
           linked1.disabled = true;
           linked2.disabled = true;
		}

	}

	function initCategories() {
			var etype = document.CategoryForm.type;
			var index = etype.selectedIndex;

			var value = 0;
			value = etype.options[index].value;
			//alert(value);
			if (value) TypeChanged(value);
	}

</SCRIPT>

  <!-- article categories list -->
  <table width="100%" border="0" align="center" cellspacing="1" cellpadding="2">
    <colgroup>
        <col id="category">
        <col id="type">
        <col id="free">
        <col id="premium">
        <col id="linked categories">
        <col id="order">
        <col id="action">
    </colgroup>

    <list:LIST id='List'>
    <tr align="left">
    	<td colspan="7" class="whiteheader">
    		Manage article categories
		</td>
    </tr>

    <tr class="header">
        <th>Category</th>
        <th>Type</th>
        <th>Free</th>
        <th>Premium</th>
        <th>Linked categories</th>
        <th>Order</th>
        <th> &nbsp; </th>
    </tr>
    <list:ITEM>
      <tr class="{$Parity}">
        <td>
        	{$name}
        </td>
        <td>{$type_show}</td>
        <td>{$free_show}</td>
        <td>{$premium_show}</td>
        <td>{$linked_categories}</td>
        <td>{$sortOrder}</td>

        <td class="left">
        	<html:link url="/delete" param="category_id">Delete</html:link>
        	<html:link url="/edit" param="category_id">Edit</html:link>
        </td>
      </tr>
    </list:ITEM>

    <tr align="left">
    	<td colspan="7" class="whiteheader">
    		Manage article categories
		</td>
     </tr>
  </table>
</list:LIST>

<hr>



<!-- Category item edit form -->
<form id="CategoryForm" name="CategoryForm" method="post" action="" runat="server">
	<input name="category_id" type="hidden" id="category_id" runat="server">

    <table width="100%" border="0" align="center" cellspacing="2" cellpadding="3">
    <tr align="left">
    	<td class="whiteheader_center" colspan="3">
    		<core:optional for="category_id">
    			Edit the category {$name} (ID: {$category_id})
            </core:optional>
            <core:default for="category_id">
            	Create a new category
            </core:default>
         </td>
     </tr>

     <core:default for="supress_errors">
    <ERRORSUMMARY id='Summary' runat="server">
        <tr valign="top">
          <td width="{width}">Errors: &nbsp;</td>
          <td colspan="2" class="left">
          	<FONT COLOR="RED">
          		<list:ITEM> {$ErrorMessage} &nbsp; </list:ITEM>
          	</FONT>
          </td>
        </tr>
     </ERRORSUMMARY>
     </core:default>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="name" runat="server">Category name:</label>
       </td>
       <td class="form_field">
      	 <input type="text" name='name' id='name' size="64" runat="server"/>
      	 Provide the category name
       </td>
       <td class="small">

       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="name" runat="server">Category type:</label>
       </td>
       <td class="form_field">
         <select name='type' id='type' onchange="TypeChanged(this.value);" runat="server">
      	 </select>
      	 Choose the category type
       </td>
       <td class="small">
       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="name" runat="server">Sort Order:</label>
       </td>
       <td class="form_field">
      	 <input type="text" name='sortOrder' id='sortOrder' size="8" runat="server"/>
      	 Provide the sort order number
       </td>
       <td class="small">

       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="free" runat="server">Free content:</label>
       </td>
       <td class="form_field">
      	 <input type="checkbox" name='normal' id='normal' value="1" runat="server"/>
      	 Specify whether the content category can be free
       </td>
       <td class="small">

       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="premium" runat="server">Premium content:</label>
       </td>
       <td class="form_field">
      	 <input type="checkbox" name='premium' id='premium' value="1" runat="server"/>
      	 Specify whether the content category can be premium
       </td>
       <td class="small">

       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="linked" runat="server">Linked categories:</label>
       </td>
       <td class="form_field">
      	 <select name='linked1[]' id='linked1' size="8" multiple runat="server">
      	 </select>
         <select name='linked2[]' id='linked2' size="8" multiple runat="server">
      	 </select>
       </td>
       <td class="small">

       </td>
     </tr>

     <tr>
      <td class="whiteheader_center" colspan="3">&nbsp;</td>
	 </tr>

     <tr>
      <td>&nbsp;</td>
      <td class="form_field">

      		<core:default for="category_id">
      			<input type="submit" name="create" value="Create" runat="server">
            </core:default>
            <core:optional for="category_id">
      			<input type="submit" name="save" value="Save" runat="server">
                <!--<input type="submit" name="delete" value="Delete" runat="server">-->
            </core:optional>
            <input type="submit" name="clean" value="Clean" runat="server">
      </td>
	</tr>
</table>


</form>

<SCRIPT language="javascript">
	initCategories();
</SCRIPT>



